/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Chat;

import java.awt.TextArea;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

/**
 *
 * @author snake_gt
 */
public class HiloCliente implements Runnable {
      private Socket socket;
    private boolean bandera;
    private TextArea area;
    public HiloCliente(Socket s, TextArea a){
        socket = s;
        area = a;
    }

    public void run() {
        bandera=true;
       while(bandera){
            try {
                DataInputStream in = new DataInputStream(socket.getInputStream());
                String cad = in.readUTF();
                area.setText(area.getText()+cad+"\n");
            } catch (IOException ex) {
                bandera=false;
            }

       }
    }

    public void stop(){
        bandera=false;
    }

}
